import Vue from 'vue'
import VueRouter from 'vue-router'

Vue.use(VueRouter)

const routes = [
  {
    path: '/',
    name: 'Homepage',
    meta: {
      title: '掌上警务数据'
    },
    component: () => import(/* webpackChunkName: "Homepage" */ '../views/Homepage.vue')
  },
  {
    path: '/people',
    name: 'People',
    meta: {
      title: '人口管理数据'
    },
    component: () => import(/* webpackChunkName: "People" */ '../views/People.vue')
  },
  {
    path: '/fenju',
    name: 'Fenju',
    meta: {
      title: '流动人员总数'
    },
    component: () => import(/* webpackChunkName: "People" */ '../views/fenju.vue')
  },
  {
    path: '/paichusuo',
    name: 'Paichusuo',
    meta: {
      title: '流动人员总数'
    },
    component: () => import(/* webpackChunkName: "People" */ '../views/paichusuo.vue')
  },
  {
    path: '/shequ',
    name: 'Shequ',
    meta: {
      title: '流动人员总数'
    },
    component: () => import(/* webpackChunkName: "People" */ '../views/shequ.vue')
  }
]

const router = new VueRouter({
  mode: 'history',
  base: process.env.BASE_URL,
  routes
})

router.beforeEach((to, from, next) => {
  if (to.meta.title) {
    document.title = to.meta.title
  }

  next()
})

export default router
